// part1:C11:ex11.4.cpp
// total of words, ignore Uppercase alpha.
#include <corecrt.h>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

string& trans(string& s)
{
    for (int pos = 0; pos < s.size(); pos++) 
    {
        if (s[pos] >= 'A' && s[pos] <= 'Z') 
        {
            s[pos] -= ('A' - 'a');
        }
        else if (s[pos] == ',' || s[pos] == '.')
        {
            s.erase(pos, 1);
        }
    }
    return s;
}

int main(int argc, char *argv[])
{
    ifstream in(argv[1]);
    if (!in) 
    {
        cout << "failed open input file" << endl;
        exit(1);
    }

    map<string, size_t> word_count;
    string word;
    while (in >> word) 
    {
        ++word_count[word];
        for (const auto& w : word_count)
        {
            cout << w.first << " is : " << w.second << endl;
        }
    }
    return 0;
}